﻿@model XieCan.AspMVC.ViewModels.LoginViewModel

@{
    ViewBag.Title = "Login";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@section styles{
    <style type="text/css">
        .vcode img {
            height: 34px;
        }

        .vcode * {
            display: inline-block;
        }
    </style>
}

@section scripts{
    <script type="text/javascript">
        $(function () {
            $(".vcode img").click(function () {
                var random = Math.random();
                $(this).attr("src", "@Url.Action("GetCode","Account")?id=" + random)
            }).prev().css("width", $("#Password").width() - 116 + "px");
        })
    </script>
}

@using (Html.BeginForm())
{
    @Html.AntiForgeryToken()

    <div class="form-horizontal">
        <div class="login-logo">
            欢迎来到<b>谢灿软件工作室</b>
        </div>
        <hr />
        @Html.ValidationSummary(true, "", new { @class = "text-danger" })

        <div class="form-group">
            @Html.LabelFor(model => model.Account, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.EditorFor(model => model.Account, new { htmlAttributes = new { @class = "form-control", placeholder = "请输入账号" } })
                @Html.ValidationMessageFor(model => model.Account, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Password, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                @Html.PasswordFor(model => model.Password, new { @class = "form-control", placeholder = "请输入密码" })
                @Html.ValidationMessageFor(model => model.Password, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.Code, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10 vcode">
                @Html.EditorFor(model => model.Code, new { htmlAttributes = new { @class = "form-control", placeholder = "请输入验证码" } })
                <img src="@Url.Action("GetCode","Account")" alt="验证码" />
                <br />
                @Html.ValidationMessageFor(model => model.Code, "", new { @class = "text-danger" })
            </div>
        </div>

        <div class="form-group">
            @Html.LabelFor(model => model.RemberMe, htmlAttributes: new { @class = "control-label col-md-2" })
            <div class="col-md-10">
                <div class="checkbox">
                    @Html.EditorFor(model => model.RemberMe)
                    @Html.ValidationMessageFor(model => model.RemberMe, "", new { @class = "text-danger" })
                </div>
            </div>
        </div>

        <div class="form-group">
            <div class="col-md-offset-2 col-md-10">
                <input type="submit" value="登录" class="btn btn-default" /> @*@Html.ActionLink("Back to List", "Index")*@
            </div>
        </div>
    </div>
}
